package zoran.wang.processer;/**
 * description：
 *
 * @author wangzhuo
 * @date 2022/3/21 10:09
 * @Email zoranwang@yeah.net
 */

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

/**
 * @program: spring-demo
 * @description: 监测bean的初始化
 * @author: wangzhuo
 * @create: 2022-03-21 10:09
 **/
public class MyBeanPostProcesser implements BeanPostProcessor {
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {

        System.out.println("Initialization start..." + beanName);

        return BeanPostProcessor.super.postProcessBeforeInitialization(bean, beanName);
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {

        System.out.println("Initialization end..." + beanName);

        System.out.println("=========================================");

        return BeanPostProcessor.super.postProcessAfterInitialization(bean, beanName);
    }
}
